﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace PremisPublisher.Common
{
    /*
 
sql语法高亮配置文件读取，来自网络，进行适当修改
* 
* 修改：张鹏 
* 日期：2016.5
 
*/


    class sql_keyword_reader
    {
        public static readonly sql_keyword_reader instance = new sql_keyword_reader();

        string XMLPATH = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "sql_syntax.xml");

        public IEnumerable<string> words;

        public static sql_keyword_reader GetInstance()
        { return instance; }

        private sql_keyword_reader()
        {
            words = ReadContent();
        }

        private IEnumerable<string> ReadContent()
        {

            return (from item in XDocument.Load(XMLPATH).Element("{http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008}SyntaxDefinition").Elements("{http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008}RuleSet").Elements("{http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008}Keywords").Elements("{http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008}Word")
                    select item.Value).ToList();

            //return (from item in XDocument.Load(XMLPATH).Element("SyntaxDefinition").Element("RuleSet").Element("Keywords").Elements("Word")
            //        select item.Value
            //            ).ToList();
        }
    }
}
